macos: allow pointer release event outside surface coords
authorChristian Hergert <chergert@redhat.com>
Wed, 14 Oct 2020 22:42:45 +0000 (15:42 -0700)
committerChristian Hergert <chergert@redhat.com>
Wed, 14 Oct 2020 22:45:50 +0000 (15:45 -0700)
This helps with grab situations so that we can end it when releasing
the pointer buttons outside of the window coordinates.

gdk/macos/gdkmacosdisplay-translate.c

index 41b738f99d6e6c2791c1d8af1bf1a768bd09ad90..5ed44d3592632a10beae6f1edc57c88afb321da4 100644 (file)
@@ -209,11 +209,6 @@ fill_button_event (GdkMacosDisplay *display,
   g_assert (GDK_IS_MACOS_DISPLAY (display));
   g_assert (GDK_IS_MACOS_SURFACE (surface));
 
-  /* Ignore button events outside the window coords */
-  if (x < 0 || x > GDK_SURFACE (surface)->width ||
-      y < 0 || y > GDK_SURFACE (surface)->height)
-    return NULL;
-
   seat = gdk_display_get_default_seat (GDK_DISPLAY (display));
   state = get_keyboard_modifiers_from_ns_event (nsevent) |
          _gdk_macos_display_get_current_mouse_modifiers (display);
@@ -238,6 +233,14 @@ fill_button_event (GdkMacosDisplay *display,
       g_assert_not_reached ();
     }
 
+  /* Ignore button press events outside the window coords but
+   * allow for button release which can happen during grabs.
+   */
+  if (type == GDK_BUTTON_PRESS &&
+      (x < 0 || x > GDK_SURFACE (surface)->width ||
+       y < 0 || y > GDK_SURFACE (surface)->height))
+    return NULL;
+
   return gdk_button_event_new (type,
                                GDK_SURFACE (surface),
                                gdk_seat_get_pointer (seat),